<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            function formatDate(date) {
                let y = date.getFullYear();
                let month = date.getMonth() + 1;
                let d = date.getDate();
                let h = date.getHours();
                let m = date.getMinutes();
                let s = date.getSeconds();
                return `${y}/${month}/${d}  ${h}:${m}:${s}`;
            }
            console.log(formatDate(new Date()));
            function intervalDate(date1, date2) {
                let d1 = new Date(date1).valueOf();
                let d2 = new Date(date2).valueOf();
                let interval = (d2 - d1) / 1000 / 60 / 60 / 24;
                return interval;
            }
            console.log(
                intervalDate(
                    new Date("2022/08/06 12:00:00"),
                    new Date("2022/08/08 12:00:00")
                )
            );
        </script>
    </body>
</html>
